package com.atguigu.tingshu.album.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author mgx
 * @version 1.0
 * @date 2023/12/4 23:00
 * @desciption: Minio客户端对象注入
 */
@Configuration
public class MinIOConfig {

    @Autowired
    private MinioConstantProperties props;

    /**
     * 注册操作MInIO客户端对象
     * @return
     */
    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder()
                        .endpoint(props.getEndpointUrl())
                        .credentials(props.getAccessKey(), props.getSecreKey())
                        .build();
    }
}
